﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web.Configuration;
using Formsy.Config.Providers;

namespace Formsy.Config
{
    public sealed class Settings : ConfigurationSectionGroup
    {
        public static string SectionName = "FormsySettings";


        #region Singleton definition

        private static readonly Settings m_settings;
        private Settings() { }
        static Settings()
        {
            Configuration config = WebConfigurationManager.OpenWebConfiguration("~\\Web.config");
            m_settings = config.GetSectionGroup(SectionName) as Settings;
        }
        public static Settings Instance
        {
            get { return m_settings; }
        }

        #endregion

        
        [ConfigurationProperty("FormsyAppSettings")]
        public FormsyAppSettings FormsyAppSettings
        {
            get
            {
                return (FormsyAppSettings)base.Sections["FormsyAppSettings"];
            }
        }


        [ConfigurationProperty("CustomFieldProviderSettings")]
        public CustomFieldProviderSettings CustomFieldProviderSettings
        {
            get
            {
                return (CustomFieldProviderSettings)base.Sections["CustomFieldProviderSettings"];
            }
        }


        [ConfigurationProperty("DataSourceProviderSettings")]
        public DataSourceProviderSettings DataSourceProviderSettings
        {
            get
            {
                return (DataSourceProviderSettings)base.Sections["DataSourceProviderSettings"];
            }
        }

        [ConfigurationProperty("DataStoreProviderSettings")]
        public DataStoreProviderSettings DataStoreProviderSettings
        {
            get
            {
                return (DataStoreProviderSettings)base.Sections["DataStoreProviderSettings"];
            }
        }

        [ConfigurationProperty("EmailProviderSettings")]
        public EmailProviderSettings EmailProviderSettings
        {
            get
            {
                return (EmailProviderSettings)base.Sections["EmailProviderSettings"];
            }
        }

        [ConfigurationProperty("FileSystemProviderSettings")]
        public FileSystemProviderSettings FileSystemProviderSettings
        {
            get
            {
                return (FileSystemProviderSettings)base.Sections["FileSystemProviderSettings"];
            }
        }


        [ConfigurationProperty("PrePopulateProviderSettings")]
        public PrePopulateProviderSettings PrePopulateProviderSettings
        {
            get
            {
                return (PrePopulateProviderSettings)base.Sections["PrePopulateProviderSettings"];
            }
        }
        
        
        [ConfigurationProperty("RegionalizationProviderSettings")]
        public RegionalizationProviderSettings RegionalizationProviderSettings
        {
            get
            {
                return (RegionalizationProviderSettings)base.Sections["RegionalizationProviderSettings"];
            }
        }



        [ConfigurationProperty("ValidationProviderSettings")]
        public ValidationProviderSettings ValidationProviderSettings
        {
            get
            {
                return (ValidationProviderSettings)base.Sections["ValidationProviderSettings"];
            }
        }

    }
}
